package top.yueyazhui.valid.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.yueyazhui.valid.bean.Response;
import top.yueyazhui.valid.entity.User;
import top.yueyazhui.valid.service.IUserService;

import javax.validation.Valid;

/**
 * <p>
 * 用户 前端控制器
 * </p>
 *
 * @author yueyazhui
 * @since 2022-09-05
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    IUserService userService;

    @PostMapping("/add")
    public Response addUser(@Valid @RequestBody User user) {
        if (userService.addUser(user) == 1) {
            return Response.success("添加成功", user);
        }
        return Response.error("添加失败");
    }
}
